<template>
	<view v-if="showFlag">
		<view class="list borderBottom1" v-for="(item, index) in list" :key="index">
			<view class="list_top">
				<image :src="item.avatar" mode=""></image>
				<text>{{ plusXing(item.nickname,1,1) }}</text>
			</view>
			<view class="list_date">
				<text>{{ item.createdate }}</text>
				<view style="position: relative;top: 4rpx;left: 26rpx;"><uni-rate size="20" disabled="true" :value="item.star"></uni-rate></view>
			</view>
			<view class="list_content">
				<text>{{ item.content }}</text>
			</view>
			<view class="detail">
				<view class="detail_name">
					<text>学员：</text>
					<text>******</text>
				</view>
				<view class="detail_name">科目：{{ item.title }}</view>
				<view class="detail_name">圈数：{{ item.yuyuenumber }}</view>
			</view>
		</view>
		<view class="loading">{{loadingText}}</view>
	</view>
</template>

<script>
import { evaluate } from '@/api/teacher/evaluate/evaluate.js';
import uniRate from '@/components/uni-rate/uni-rate.vue';
export default {
	components: {
		uniRate
	},
	data() {
		return {
			loadingText: '加载中...', //加载状态
			list: [
				// {
				// 	img:"../../static/img/index/12.JPG",
				// 	date:'2-27',
				// 	star:4,
				// 	nickName:'飞天小象',
				// 	content:'教练非常专业。',
				// 	name:'****',
				// 	lesson:'科目一',
				// 	round:1
				// },
			],
			showFlag: false,
			page:1,
			
		};
	},
	async onLoad() {
		let res = await evaluate();
		this.getTeacherList(res)
		this.showFlag = true;
	},
	// 监听触底
	onReachBottom() {
		this.loadMore()
	},
	methods: {
		getTeacherList(res){
			if (res.data.data.length == 0) {
				this.loadingText = "没有数据了！";
			} else if (res.data.data.length < 10) {
				this.loadingText = "没有数据了！";
			} else {
				this.loadingText = "加载中";
			}
			if (this.page == 1) {
				this.list = res.data.data;
			} else {
				this.list = this.list.concat(res.data.data)
			}
		},
		async loadMore(){
			let res = await evaluate(++this.page);
			this.getTeacherList(res)
		},
		plusXing(str, frontLen, endLen) {
			var len = str.length - frontLen - endLen;
			var xing = '';
			for (var i = 0; i < len; i++) {
				xing += '*';
			}
			return str.substring(0, frontLen) + xing + str.substring(str.length - endLen);
		}
	}
};
</script>

<style lang="scss">
@import './css/teacherEvaluate.scss';
</style>
